﻿using System;
using EPiServer.Core;
using TemplateFoundation.Core;
using TemplateFoundation.PageTypes;

namespace TemplateFoundation.PageTemplates
{
    /// <summary>
    /// Base class for pages serving as data containers without any associated public page template
    /// </summary>
    public class DataContainerTemplateBase : PageTemplateBase<PageTypeBase>
    {
        /// <summary>
        /// Redirects the user to the start page if not authenticated
        /// </summary>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (!User.Identity.IsAuthenticated)
            {
                Response.Redirect(PageReference.StartPage.GetPage().LinkURL, true);
            }
        }
    }
}
